cmake_minimum_required(VERSION 3.16)

project(MediaItem VERSION 0.1 LANGUAGES CXX)

set(CMAKE_AUTOMOC ON)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(QT_QML_OUTPUT_DIRECTORY  ${CMAKE_BINARY_DIR})

find_package(Qt6 6.2 COMPONENTS Quick Widgets ShaderTools REQUIRED)

qt_add_library(MediaItem SHARED)
qt_add_qml_module(MediaItem
    OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/MediaItem
    URI MediaItem
    VERSION 1.0
    QML_FILES
    SOURCES
        VideoItem.h
        VideoItem.cpp
        VideoItem2.h
        VideoItem2.cpp
        GlDynamicTexture.h
        GlDynamicTexture.cpp
)
target_include_directories(MediaItem PRIVATE ${VLC_INCLUDE_PATH})
qt_add_resources(MediaItem "images"
	PREFIX
		"/"
	FILES
		images/model-sample.png
        images/loginLogo.png
)


qt6_add_shaders(MediaItem "shaders"
    BATCHABLE
    PRECOMPILE
    OPTIMIZED
    PREFIX
        "/content"
    FILES
        "shaders/Video.vert"
        "shaders/Video.frag"
)

set_target_properties(MediaItem PROPERTIES
    MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
    MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
    MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
    MACOSX_BUNDLE TRUE
    WIN32_EXECUTABLE TRUE
)

target_compile_definitions(MediaItem
    PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)
target_link_libraries(MediaItem
    PRIVATE Qt6::Quick
    PRIVATE Qt6::Widgets
    PRIVATE ${VLC_LIBRARY}
)
install(TARGETS MediaItem     
    BUNDLE  DESTINATION .
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install(DIRECTORY ${EXECUTABLE_OUTPUT_PATH}/MediaItem DESTINATION ${CMAKE_INSTALL_QMLDIR})

install(DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/MediaItem DESTINATION ${CMAKE_INSTALL_PREFIX}/qml)
set_property(TARGET MediaItem PROPERTY FOLDER "Quick Plugins")
target_include_directories(MediaItem PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

